class PollersController < ApplicationController
  # GET /pollers
  # GET /pollers.xml
  def index
    @pollers = Poller.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @pollers }
    end
  end

  # GET /pollers/1
  # GET /pollers/1.xml
  def show
    @poller = Poller.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @poller }
    end
  end

  # GET /pollers/new
  # GET /pollers/new.xml
  def new
    @poller = Poller.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @poller }
    end
  end

  # GET /pollers/1/edit
  def edit
    @poller = Poller.find(params[:id])
  end

  # POST /pollers
  # POST /pollers.xml
  def create
    @poller = Poller.new(params[:poller])

    respond_to do |format|
      if @poller.save
        flash[:notice] = 'Poller was successfully created.'
        format.html { redirect_to(@poller) }
        format.xml  { render :xml => @poller, :status => :created, :location => @poller }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @poller.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /pollers/1
  # PUT /pollers/1.xml
  def update
    @poller = Poller.find(params[:id])

    respond_to do |format|
      if @poller.update_attributes(params[:poller])
        flash[:notice] = 'Poller was successfully updated.'
        format.html { redirect_to(@poller) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @poller.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /pollers/1
  # DELETE /pollers/1.xml
  def destroy
    @poller = Poller.find(params[:id])
    @poller.destroy

    respond_to do |format|
      format.html { redirect_to(pollers_url) }
      format.xml  { head :ok }
    end
  end

end
